<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<script type="text/javascript" src="js/jquery.itextclear.js"></script>
<script type="text/javascript" src="${ctx}/js/global_util.js"></script>
<script type="text/javascript">
	$(document)
			.ready(
					function() {
						$(
								'input[type=text], input[type=password], input[type=url], input[type=email], input[type=number], textarea',
								'.form').iTextClear();
					});
</script>
<!-- jQplot CSS -->

<link rel="stylesheet" media="screen" href="${ctx}/css/Tree.css" />
<!-- jQplot CSS END -->

<!-- DATATABLES CSS -->
<link rel="stylesheet" media="screen" href="lib/datatables/css/vpad.css" />
<script type="text/javascript"
	src="lib/datatables/js/jquery.dataTables.js"></script>
<!-- DATATABLES CSS END -->

<h1 class="page-title">${listTitle}</h1>
<div class="container_12 clearfix leading">
	<%@include file="/WEB-INF/pages/common/common_orgtab.jsp"%>
	<!--control layer -->
	<s:if test="#request.module == 'invite'">
		<s:if test="#request.p == 'apply'">
			<div class="tabs side grid_12 leading">
				<div class="clear"></div>
				<div class="grid_12">
					<div class="form-action clearfix">
						<p>
							<input type="checkbox" value="1"  id="form-updates-i"
								onchange="checkAll(this,'chk_invite')" /><label
								for="form-updates-i">全选</label> <a class="button"
								href="javascript:void(0)" onclick="deleteInvites()">批量删除</a> <a
								class="button" href="#invite/invite_apply.xhtml"><span
								style="background: url(${ctx}/images/img/add.png)" class="icon">&nbsp;</span>添加</a>
						</p>
					</div>

				</div>
			</div>
		</s:if>
	</s:if>
	<s:elseif test="#request.module == 'invite_arrange'">
		<div class="tabs side grid_12 leading">
			<div class="clear"></div>
			<div class="grid_12">
				<div class="form-action clearfix">
					<p>
						<input type="checkbox"value="1" id="form-updates-ia"
							onchange="checkAll(this,'chk_invite_arrange')" /><label
							for="form-updates-ia">全选</label> <a
							class="button" href="javascript:void(0)" onclick="handleInviteArrange('modify')"><span
							style="background: url(${ctx}/images/img/add.png)" class="icon">&nbsp;</span>修改招聘渠道</a>
						<a class="button" href="javascript:void(0)" onclick="handleInviteArrange('add')"><span
							style="background: url(${ctx}/images/img/add.png)" class="icon">&nbsp;</span>添加招聘渠道</a>
					</p>
				</div>

			</div>
		</div>
	</s:elseif>
    <s:elseif test="#request.module == 'interview_arrange'">
        <div class="tabs side grid_12 leading">
            <div class="clear"></div>
            <div class="grid_12">
                <div class="form-action clearfix">
                    <p>
                        <input type="checkbox" id="form-updates-ita" value="1"
                               onchange="checkAll(this,'chk_interview_arrange')" /><label
                            for="form-updates-ita">全选</label> <a class="button"
                                                              href="javascript:void(0)" onclick="deleteInterviewArranges()">批量删除</a> <a
							class="button" href="#invite/interview_arrtent.xhtml"><span
							style="background: url(${ctx}/images/img/add.png)" class="icon">&nbsp;</span>添加</a>
                    </p>
                </div>

            </div>
        </div>
    </s:elseif>
	<!--control layer end-->
</div>

<div class="clear"></div>
<script type="text/javascript">
	/**
	* 删除招聘申请
	*/
	function deleteInvites() {
		var checkIds = new Array();
		$("input[type='checkbox'][name='chk_invite']").each(function() {
			if (this.checked) {
				checkIds.push(this.value);
			}
		});
		if (checkIds.length == 0) {
			return;
		}
		if (confirm("确定要删除选中的数据吗？")) {
			doDeleteDatas("${ctx}/invite/invite_delete.xhtml",checkIds.join(","))
		}
	}

    /**
     * 删除招聘安排
     */
    function deleteInviteArranges() {
        var checkIds = new Array();
        $("input[type='checkbox'][name='chk_invite_arrange']").each(function() {
            if (this.checked) {
                checkIds.push(this.value);
            }
        });
        if (checkIds.length == 0) {
            return;
        }
        if (confirm("确定要删除选中的数据吗？")) {
            doDeleteDatas("${ctx}/invite/invite_delete_arrange.xhtml",checkIds.join(","))
        }
    }

    /**
    *处理招聘渠道
    * @param mode
     */
    function handleInviteArrange(operation){
        var checkIds = new Array();
        $("input[type='checkbox'][name='chk_invite_arrange']").each(function() {
            if (this.checked) {
                checkIds.push(this.value);
            }
        });
        if (checkIds.length == 0) {
        	alert("请选择要操作的数据")
            return;
        }
        location.href = "${ctx}/index.xhtml#invite/invite_fashion.xhtml?ids="+checkIds + "&operation=" + operation;
    }

    /**
     * 删除面试安排数据
     */
    function deleteInterviewArranges(){
        var checkIds = new Array();
        $("input[type='checkbox'][name='chk_interview_arrange']").each(function() {
            if (this.checked) {
                checkIds.push(this.value);
            }
        });
        if (checkIds.length == 0) {
            return;
        }
        if (confirm("确定要删除选中的数据吗？")) {
            doDeleteDatas("${ctx}/invite/interview_delete_arrange.xhtml",checkIds.join(","))
        }
    }

    /**
     * 删除指定数据集
     * @param url
     * @param ids
     */
	function doDeleteDatas(url,ids) {
		$.ajax({
			type : "get",
			url : url,
			data: {"ids":ids},
			dataType : "json",
			success : function(data) {
				// load the grade list
				//currentTabOrgId
				if(typeof(currentTabOrgId) == 'number'){
					loadListContent("${ctx}${listAction}", currentTabOrgId);
				}else{
					loadListContent("${ctx}${listAction}",${organizationId});
				}
			}
		});
	}

	
</script>